#include<iostream>
#include<string>
#include<time.h>

std::string gettime()
{
    //获取时间戳
    time_t t = time(nullptr);
    struct tm* add = ::localtime(&t);
    char bufftime[32];
    snprintf(bufftime,sizeof(bufftime),"%d-%d-%d %d:%d:%d\n",
    add->tm_year+1900,
    add->tm_mon+1,
    add->tm_mday,
    add->tm_hour,
    add->tm_min,
    add->tm_sec
    );
    return bufftime;
}